package com.goods.business.converter;
import com.goods.common.model.business.ProductCategory;
import com.goods.common.vo.business.ProductCategoryTreeNodeVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator
 *
 */
@Component
public class ProductCategoryTreeNodeConverter {

    public List<ProductCategoryTreeNodeVO> convertProductCategoryVOList(List<ProductCategory> productCategoryList){
        List<ProductCategoryTreeNodeVO> productCategoryTreeNodeVOS = new ArrayList<>();
        if (!CollectionUtils.isEmpty(productCategoryList)){
            for (ProductCategory productCategory : productCategoryList) {
                ProductCategoryTreeNodeVO productCategoryTreeNodeVO=convertProductCategoryVO(productCategory);
                productCategoryTreeNodeVOS.add(productCategoryTreeNodeVO);
            }
        }
        return productCategoryTreeNodeVOS;

    }

    public ProductCategoryTreeNodeVO convertProductCategoryVO(ProductCategory productCategory) {
        ProductCategoryTreeNodeVO productCategoryTreeNodeVO = new ProductCategoryTreeNodeVO();
        BeanUtils.copyProperties(productCategory,productCategoryTreeNodeVO);
        return productCategoryTreeNodeVO;
    }


}
